package kr.saeildadim.androidexam_saeildamil.chapter11;

import kr.saeildadim.androidexam_saeildamil.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class Ch11_EditSelectEx extends Activity {
	EditText mEdit;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch11_editselect);
		
		mEdit = (EditText) findViewById(R.id.ch11_edittext_edit);
	}
	public void mOnClick(View v){
		switch(v.getId()){
		case R.id.ch11_edittext_btn_home:
			mEdit.setSelection(0);
			break;
		case R.id.ch11_edittext_btn_end:
			mEdit.setSelection(mEdit.getText().length());
			break;
		case R.id.ch11_edittext_btn_selblock:
			mEdit.setSelection(3,10);
			break;
		case R.id.ch11_edittext_btn_selall:
			mEdit.selectAll();
			break;
		case R.id.ch11_edittext_btn_getsel:
			int start = mEdit.getSelectionStart();
			int end = mEdit.getSelectionEnd();
			Toast.makeText(Ch11_EditSelectEx.this, "start ="+start+"end="+end, Toast.LENGTH_LONG).show();
			break;
		}	
	}
}
